package cn.itrip.auth.controller;

import cn.itrip.beans.dto.Dto;
import cn.itrip.common.DtoUtil;
import cn.itrip.common.ErrorCode;
import io.swagger.annotations.*;
import org.apache.tools.ant.taskdefs.XSLTProcess;
import org.springframework.web.bind.annotation.*;

@Api( tags= "测试接口")
@RestController
@RequestMapping(value = "/hello")
public class HelloController {

    @ApiOperation(value = "Hello 方法",httpMethod = "GET",protocols = "HTTP"
            ,notes = "详细说明")
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello(){
        return "hello itrip";
    }

    @ApiOperation(value = "用户登录",httpMethod = "POST",
            protocols = "HTTP", produces = "application/json",
            response = Dto.class,notes="根据用户名、密码进行统一认证")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="form",required=true,value="用户名",name="name",defaultValue="yao.liu2015@bdqn.cn"),
            @ApiImplicitParam(paramType="form",required=true,value="密码",name="password",defaultValue="111111"),
    })
    @RequestMapping(value="/dologin",method=RequestMethod.POST,produces= "application/json")
    public Dto dologin(
            @ApiParam( required = true, name = "name", value = "用户名",defaultValue="yao.liu2015@bdqn.cn")
            @RequestBody String name,
            @ApiParam(required = true, name = "password", value = "密码",defaultValue="111111")
            @RequestBody String password){
        return DtoUtil.returnFail("用户名密码错误", ErrorCode.AUTH_AUTHENTICATION_FAILED);
    }

}
